package leetcode.backtrace;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Lc78 {


    List<List<Integer>> ans;
    public List<List<Integer>> subsets(int[] nums) {

        ans = new ArrayList<>();
        int n = nums.length;
        for (int i = 0; i < (1 << n); i++) {
            List<Integer> temp = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                if ( ((i >> j) & 1) == 1) {
                    temp.add(nums[j]);
                }
            }
            ans.add(temp);
        }
        return ans;
    }


    public static void main(String[] args) {
        int[] nums = {1, 2, 3};
        Lc78 lc78 = new Lc78();
        System.out.println(lc78.subsets(nums));
    }
}
